//
//  WXLiveVideoCollectionViewCell.m
//  NewGuiYang
//
//  Created by 罗江 on 2018/5/25.
//  Copyright © 2018年 luojiang. All rights reserved.
//

#import "WXLiveVideoCollectionViewCell.h"

#import <WXCloudModuleCategories/UIView+LayoutMethods.h>

#import <WXCloudModuleBaseConfig/WXSystemBaseDefine.h>

#import <SDWebImage/UIImageView+WebCache.h>
#import <Masonry/Masonry.h>

@interface WXLiveVideoCollectionViewCell ()

@property (nonatomic, strong) UIImageView *imageView;
@property (nonatomic, strong) UILabel *titleLabel;

@end
@implementation WXLiveVideoCollectionViewCell
#pragma mark - life cycle
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self initialize];
    }
    return self;
}

- (void)initialize
{
    [self.contentView addSubview:self.imageView];
    [self.contentView addSubview:self.titleLabel];
    
    [_imageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.contentView.mas_centerX);
        make.top.equalTo(self.contentView).offset(10);
        make.size.mas_offset(CGSizeMake(WXWidth(40), WXHeight(40)));
    }];
    
    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_imageView.mas_bottom);
        make.left.right.equalTo(self.contentView);
        make.height.mas_offset(30);
    }];
}


-(void)setModel:(WXBaseInteractiveModel *)model
{
    _model = model;
    [_imageView sd_setImageWithURL:[NSURL URLWithString:model.iconURL] placeholderImage:[UIImage imageNamed:@"直播图标"]];
    _titleLabel.text = model.title;
}

- (UIImageView *)imageView
{
    if (_imageView == nil) {
        _imageView = [UIImageView new];
        _imageView.contentMode = UIViewContentModeScaleToFill;
        _imageView.layer.cornerRadius = 5;
        _imageView.layer.masksToBounds = YES;
    }
    return _imageView;
}
- (UILabel *)titleLabel
{
    if (_titleLabel == nil) {
        _titleLabel = [UILabel new];
        _titleLabel.font = [UIFont systemFontOfSize:14];
        _titleLabel.numberOfLines = 2;
        _titleLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _titleLabel;
}

@end
